package easy;

public class Solution_1399 {

    public int countLargestGroup(int n) {
        int max = 0;
        int[] counts = new int[37];
        int[] arr = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            int mod = i % 10;
            int temp = i / 10;
            arr[i] = arr[temp] + mod;
            counts[arr[i]]++;
            if (counts[arr[i]] > max) {
                max = counts[arr[i]];
            }
        }
        int res = 0;
        for (int count : counts) {
            if (count == max) {
                res++;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Solution_1399 model = new Solution_1399();
        System.out.println(model.countLargestGroup(13));
        System.out.println(model.countLargestGroup(2));
        System.out.println(model.countLargestGroup(15));
        System.out.println(model.countLargestGroup(24));
    }
}
